package com.drei.wolke.oauth2.authorize.routers;

import org.springframework.core.annotation.Order;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

import com.drei.wolke.oauth2.authorize.AuthorizeConfigProvider;

/** 
* @author 作者 owen E-mail: 624191343@qq.com
* @version 创建时间：2018年1月31日 下午9:11:36 
* 类说明 
*/
@Component
@Order(Integer.MAX_VALUE - 1)
public class AuthAuthorizeConfigProvider implements AuthorizeConfigProvider {

	@Override
	public boolean config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
		// TODO Auto-generated method stub
		 
		 config.antMatchers("/auth/**" ,"/auth","/oauth/token","/auth/**/**" ).permitAll();
		 
		 config.antMatchers("/test").hasAuthority("ROLE_ADMIN");
		 config.antMatchers("/mvc").hasAuthority("ROLE_HELLO");
		 config.antMatchers(HttpMethod.GET, 
					"/**/*.js",
					"/**/*.css",
					"/**/*.jpg",
					"/**/*.png",
					"/**/*.gif",
					"/**/fonts/**"
				 ).permitAll();
		 config.antMatchers(HttpMethod.GET, 
					"/**/*.html",
					"/admin/me",
					"/resource").authenticated() ;
		return true;
	}

}
